﻿@using ThirdPrize.Models;

@model VisitorTableModel

@{
    ViewBag.Title = "VisitorTable";
}

<h2>VisitorTable</h2>

<table>
    <tr>
        <td>
            <h3>App</h3>
        </td>
        <td>
            <h3>Version</h3>
        </td>
        <td>
            <h3>Platform</h3>
        </td>
        <td>
            <h3>Count</h3>
        </td>
    </tr>

    @{
        int rowNo = 1;
        int totalVisits = 0;
        string lastAppPlatform = "";
        string cssClass = "row0";


        foreach (var r in Model.Visits)
        {
            if (lastAppPlatform != r.AppName + r.Platform)
            {
                cssClass = "row0";
                lastAppPlatform = r.AppName + r.Platform;
                rowNo = (rowNo == 0 ? 1 : 0);
            }

            totalVisits = totalVisits + r.Count;
            cssClass = String.Format("row{0}", rowNo);
         
        <tr class="@cssClass">
            <td>@r.AppName</td>
            <td>@r.AppVersion</td>
            <td>@r.Platform</td>
            <td>@r.Count</td>
        </tr>
        }

    }


</table>
totalVisits visits = @totalVisits
